include(RunCTest)

function(run_InstrumentationInCTestXML USE_INSTRUMENTATION)
  if(USE_INSTRUMENTATION)
    set(ENV{CTEST_USE_INSTRUMENTATION} "1")
    set(ENV{CTEST_EXPERIMENTAL_INSTRUMENTATION} "a37d1069-1972-4901-b9c9-f194aaf2b6e0")
    set(RunCMake_USE_INSTRUMENTATION TRUE)
    set(CASE_NAME InstrumentationInCTestXML)
  else()
    set(ENV{CTEST_USE_INSTRUMENTATION} "0")
    set(ENV{CTEST_EXPERIMENTAL_INSTRUMENTATION} "0")
    set(RunCMake_USE_INSTRUMENTATION FALSE)
    set(CASE_NAME NoInstrumentationInCTestXML)
  endif()
  configure_file(${RunCMake_SOURCE_DIR}/main.c
                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/main.c COPYONLY)
  run_ctest("${CASE_NAME}")
  unset(RunCMake_USE_LAUNCHERS)
  unset(RunCMake_USE_INSTRUMENTATION)
endfunction()
run_InstrumentationInCTestXML(ON)
run_InstrumentationInCTestXML(OFF)
